#!/bin/bash

##################
log_file='./test.log'

#################

#当前时间前一分钟
#curdate=`date -d "1 minute ago" +"%Y-%m-%d %H:%M"`
curdate='2022-02-14 18:35'
#echo ${curdate}

log_err=$(cat $log_file | grep "${curdate}" | grep "ERROR")

if [ "${log_err}" ]; then
  echo "CheckTime $curdate : Error in log file,Send Email"
  /usr/bin/python3 ./send_email.py "$curdate"
else
  echo "CheckTime $curdate : The log file has no ERROR"
fi

